<?php use common\helpers\Html; ?>
<style type="text/css">
    .alert_mask{
        background: rgba(0,0,0,0.5);
        position: fixed;
        width: 100vw;
        height: 100vh;
        left: 0;
        top: 0;
    }
    .alert_container{
        background: #fff;
        width: 300px;
        border-radius:6px;
        position: absolute;
        left: 50%;
        top: 50%;
        margin-left: -150px;
        margin-top: -200px;
        padding: 10px 20px;
    }
    .alert_title{
        font-size: 16px;
        color: #666;
    }
    .alert_select{
        list-style: none;
        margin:0;
        padding: 0;
    }
    .alert_select li{
        padding: 5px 20px;
        text-align: center;
        color: #333;
        cursor: pointer;
    }
    .alert_select li.active{
        background: #A7C0DC;
        color: #fff;
    }
    .clear-fl:after{
        content:"";
        display: block;
        clear: both;
    }
    .lf{
        float: left;
    }
    .rt{
        float: right;
    }
    .alert_control {
        padding: 10px 20px;
    }
    .alert_control button{
        width: 40%;
        height: 30px;
        line-height: 26px;
        border:0;
        color: #fff;
        border-radius:4px;
    }
    .alert_cancel{
        background: #999;
    }
    .alert_comfirm{
        background: #39B0FF;
    }
</style>
<?= $html ?>

<p class="cl pd-5 mt-20">
    <span class="countProfit">盈亏统计：<?= $profit >= 0 ? Html::redSpan($profit) : Html::greenSpan($profit) ?>，</span>
    <span>交易手数：<?= $hand >= 0 ? Html::redSpan($hand, ['class' => 'countHand']) : Html::greenSpan($hand, ['class' => 'countHand']) ?>，</span>
    <span>交易额统计：<?= $amount >= 0 ? Html::redSpan($amount, ['class' => 'countAmount']) : Html::greenSpan($amount, ['class' => 'countAmount']) ?>，</span>
    <span>手续费统计：<?= $fee >= 0 ? Html::redSpan($fee, ['class' => 'countFee']) : Html::greenSpan($fee, ['class' => 'countFee']) ?></span>
</p>


<script type="text/javascript">
    function _alert(callback){
        var type = 1;
        var $dom = ('<div class="alert_mask"><div class="alert_container"><h1 class="alert_title">请选择</h1><ul class="alert_select"><li data-type="1" class="active">  盈  </li><li data-type="2">  亏  </li><li data-type="3">  取消  </li></ul><div class="clear-fl alert_control"><button class="lf alert_cancel" type="button">取消</button><button class="rt alert_comfirm " type="button">确认</button></div></div></div>');
        $("body").append($dom);
        $(".alert_cancel").click(function(){
            $(".alert_mask").remove();
        });
        $(".alert_comfirm").click(function(){
            callback(type);
            $(".alert_mask").remove();
        });
        $(".alert_select").on("click" , "li" , function(){
            $(this).addClass("active").siblings(".active").removeClass('active');
            type = $(this).data("type");
        });
    }
    window.alert = _alert;


</script>

<script>
    $(function () {
        $(".list-container").on('click', '.sellOrderBtn', function () {
            var $this = $(this);
            $.post($this.attr('href'), function (msg) {
                $.alert(msg.info, function () {
                    $this.parents('td').html($("<span>").html(msg.info).css('color', 'red'));
                });
            });
            return false;
        });
        $(".list-container").on('click', '.signBtn', function () {
            var $this = $(this);
            alert(function(value){
                $.post($this.attr('href'), {sign: value}, function (msg) {
                    if (msg.state) {
                        $.alert(msg.info || '修改成功', function () {
                            location.replace(location.href);
                        });
                    } else {
                        $.alert(msg.info);
                    }
                }, 'json');
            });
            return false;
        });
    });
</script>
